package com.huifer.wgx.geoverify;

import com.huifer.wgx.model.DetectionPointEntity;
import com.huifer.wgx.model.FieldPointEntity;
import com.huifer.wgx.model.InteriorPointEntity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * <p>Title : PointVerify </p>
 * <p>Description : 点异常查询</p>
 *
 * @author huifer
 * @date 2019-03-21
 */
public class PointVerify {

    /**
     * id单数双数判断
     *
     * @param allPoint 所有点
     * @return {"单数":[],"双数":[]}
     */
    public static List<DetectionPointEntity> onlyPoint(
            List<InteriorPointEntity> allPoint, Long verifyId, Long personnelId) {

        List<DetectionPointEntity> result = new ArrayList<>();

        List<InteriorPointEntity> singular = new ArrayList<>();
        List<InteriorPointEntity> even = new ArrayList<>();

        for (InteriorPointEntity fieldPointEntity : allPoint) {
            if (fieldPointEntity.getInteriorPointId() % 2 == 0) {
                even.add(fieldPointEntity);
            } else {
                singular.add(fieldPointEntity);
            }
        }

        for (int i = 0; i < singular.size(); i++) {
            DetectionPointEntity detectionPointEntity = new DetectionPointEntity();
            detectionPointEntity.setInteriorPointId(singular.get(i).getInteriorPointId());
            detectionPointEntity.setVerifyId(verifyId);
            detectionPointEntity.setPersonnelId(personnelId);
            detectionPointEntity.setDetecionIsok("单数通过");
            result.add(detectionPointEntity);
        }

        for (int i = 0; i < even.size(); i++) {
            DetectionPointEntity detectionPointEntity = new DetectionPointEntity();
            detectionPointEntity.setInteriorPointId(even.get(i).getInteriorPointId());
            detectionPointEntity.setVerifyId(verifyId);
            detectionPointEntity.setPersonnelId(personnelId);
            detectionPointEntity.setDetecionIsok("双数通过");
            result.add(detectionPointEntity);
        }
        return result;
    }
}
